class ActiveRecord::Errors
  def to_xml( options = {} )
    options[:root] ||= "errors"
    options[:indent] ||= 2
    options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])
    options[:builder].instruct! unless options.delete(:skip_instruct)
    options[:builder].errors do |e|
      each do |field, msg|
        e.error msg, :field => field
      end
    end
  end
end